#include<stdio.h>
#include<sys/time.h>
#include<unistd.h>

#define MAX_N   1000000
long long    arr[MAX_N];
int main(){
    
    struct timeval tv1,tv2;
    long long sum1 = 0,timelen = 0,i = 0;
    gettimeofday(&tv1,NULL);
    for(i = 0; i < MAX_N; i++){
        arr[i] = (i+1);
    }
    i = 0;
    while(i < MAX_N){
        //sum2 += (j+1);
        sum1 += arr[i++];
    }
    gettimeofday(&tv2,NULL);
    timelen = tv2.tv_usec - tv1.tv_usec;
    printf("sum of array is:%lld\ntime length is:%d us\n",sum1,timelen);
}